package org.pp.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.pp.entity.PpCategorize;
import org.pp.entity.PpGoods;
import org.pp.mapper.PpCategorizeMapper;
import org.pp.service.IPpCategorizeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.pp.store.OssStore;
import org.pp.vo.MiniappCategorizeVo;
import org.pp.vo.MiniappGoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品类别 服务实现类
 * </p>
 *
 * @author haima
 * @since 2024-06-02
 */
@Service
public class PpCategorizeServiceImpl extends ServiceImpl<PpCategorizeMapper, PpCategorize> implements IPpCategorizeService {

    @Autowired
    OssStore store;

    @Override
    public List<MiniappCategorizeVo> getNavCate() {
        List<PpCategorize> list = list(new LambdaQueryWrapper<PpCategorize>().eq(PpCategorize::getIfNav, true));
        list.forEach(e->e.setIcoUrl(store.getUrl(e.getIco())));
        return BeanUtil.copyToList(list,MiniappCategorizeVo.class);
    }

    @Override
    public List<MiniappCategorizeVo> getList(Integer type) {
        List<PpCategorize> list = list(new LambdaQueryWrapper<PpCategorize>().eq(PpCategorize::getType, type));
        list.forEach(e->e.setIcoUrl(store.getUrl(e.getIco())));
        return BeanUtil.copyToList(list,MiniappCategorizeVo.class);
    }


}
